package cn.lzd.mr.pvdemo;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * Created by lzd on 2018/4/27.
 */
public class PvMapper extends Mapper<LongWritable, Text, Text, IntWritable> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        if(line.indexOf("downloader retry mechanism") != -1){
            context.write(new Text("retry"),new IntWritable(1));
        }else if(line.endsWith("code  = 504")){
            context.write(new Text("504"),new IntWritable(1));
        }
    }
}
